<template>
	<div class="layout-padding">
		<div class="layout-padding-auto layout-padding-view">
			<!-- formType //1-给我们留言 2-咨询报价3-在线报修 -->
			<el-tabs v-model="activeName" @tab-click="handleClick">
				<el-tab-pane label="留言" name="1"></el-tab-pane>
				<el-tab-pane label="咨询报价" name="2"></el-tab-pane>
				<el-tab-pane label="在线报修" name="3"></el-tab-pane>
			</el-tabs>
			<el-row class="ml10" v-show="showSearch">
				<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
					<el-form-item label="客户姓名" prop="clientName">
						<el-input placeholder="请输入 客户姓名" style="max-width: 180px" v-model="state.queryForm.clientName" />
					</el-form-item>
					<el-form-item>
						<el-button @click="getDataList" icon="search" type="primary">
							{{ $t('common.queryBtn') }}
						</el-button>
						<el-button @click="resetQuery" icon="Refresh">{{ $t('common.resetBtn') }}</el-button>
					</el-form-item>
				</el-form>
			</el-row>
			<el-row>
				<div class="mb8" style="width: 100%">
					<right-toolbar
						:export="'false'"
						@exportExcel="exportExcel"
						@queryTable="getDataList"
						class="ml10"
						style="float: right; margin-right: 20px"
						v-model:showSearch="showSearch"
					></right-toolbar>
				</div>
			</el-row>
			<el-table
				:data="state.dataList"
				style="width: 100%"
				v-loading="state.loading"
				border
				:cell-style="tableStyle?.cellStyle"
				:header-cell-style="tableStyle?.headerCellStyle"
			>
				<el-table-column label="客户姓名" prop="clientName" show-overflow-tooltip />
				<el-table-column label="手机号" prop="mobile" width="120" show-overflow-tooltip />
				<el-table-column label="邮箱" prop="email" show-overflow-tooltip />
				<el-table-column label="公司" prop="company" show-overflow-tooltip />
				<el-table-column label="意向产品与服务" prop="interestProducts" width="130" show-overflow-tooltip v-if="activeName == '2'" />
				<el-table-column :label="activeName == '2' ? '留言' : '咨询内容描述'" prop="message" show-overflow-tooltip v-if="activeName != '1'" />
				<el-table-column label="送修仪器品牌+型号" prop="repairInstrumentBandModel" width="150" show-overflow-tooltip v-if="activeName == '1'" />
				<el-table-column label="送修仪器情况说明" prop="repairInstrumentDesc" width="150" show-overflow-tooltip v-if="activeName == '1'" />
				<el-table-column label="咨询类别" prop="consultingServiceType" width="150" show-overflow-tooltip v-if="activeName == '3'" />
				<el-table-column label="租赁时间（月）" prop="leasePeriod" width="150" show-overflow-tooltip v-if="activeName == '3'" />
				<el-table-column label="创建时间" prop="createTime" show-overflow-tooltip />
			</el-table>
			<pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle" v-bind="state.pagination" />
		</div>
	</div>
</template>

<script lang="ts" name="systemPost" setup>
import { BasicTableProps, useTable } from '/@/hooks/table';
import { fetchList, delObjs } from '/@/api/qytest/sysClientInfo';
import { useMessage, useMessageBox } from '/@/hooks/message';
import { useI18n } from 'vue-i18n';
const type = ref([
	{ label: '联系我们-入口', value: '2' },
	{ label: '维修-入口', value: '1' },
	{ label: '产品详情-入口', value: '3' },
]) as any;
// 引入组件
const { t } = useI18n();
// 搜索变量
const queryRef = ref();
const showSearch = ref(true);
// 多选变量
const selectObjs = ref([]) as any;
const multiple = ref(true);
const activeName = ref('1');
import type { TabsPaneContext } from 'element-plus';
const state: BasicTableProps = reactive<BasicTableProps>({
	queryForm: {
		formType: activeName.value,
	},
	pageList: fetchList,
});

//  table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, downBlobFile, tableStyle } = useTable(state);
// 清空搜索条件
const resetQuery = () => {
	// 清空搜索条件
	queryRef.value.resetFields();
	// 清空多选
	selectObjs.value = [];
	getDataList();
};
// 导出excel
const exportExcel = () => {
	downBlobFile('/admin/post/export', state.queryForm, 'post.xlsx');
};

const handleClick = (tab: TabsPaneContext, event: Event) => {
	state.queryForm.formType = tab.props.name;
	getDataList();
};
</script>
